package com.mjk.manager.magicapi.core.core.model;


import java.util.Objects;

public class MagicEntity extends Attributes<Object> {

    protected String id;

    protected String script;

    protected String groupId;

    protected String groupName;

    protected String name;
    /**
     * 当前entity的路径
     */
    protected String ePath;

    protected Long createTime;

    protected Long updateTime;

    protected String lock;

    protected String createBy;

    protected String updateBy;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getScript() {
        return script;
    }

    public void setScript(String script) {
        this.script = script;
    }

    public Long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Long createTime) {
        this.createTime = createTime;
    }

    public Long getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Long updateTime) {
        this.updateTime = updateTime;
    }

    public String getGroupId() {
        return groupId;
    }

    public void setGroupId(String groupId) {
        this.groupId = groupId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getLock() {
        return lock;
    }

    public void setLock(String lock) {
        this.lock = lock;
    }

    public String getCreateBy() {
        return createBy;
    }

    public void setCreateBy(String createBy) {
        this.createBy = createBy;
    }

    public String getUpdateBy() {
        return updateBy;
    }

    public String getGroupName() {
        return groupName;
    }

    public void setGroupName(String groupName) {
        this.groupName = groupName;
    }
    public void setUpdateBy(String updateBy) {
        this.updateBy = updateBy;
    }

    public String getePath() {
        return ePath;
    }

    public void setePath(String ePath) {
        this.ePath = ePath;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof MagicEntity)) return false;
        MagicEntity that = (MagicEntity) o;
        return Objects.equals(id, that.id) && Objects.equals(script, that.script) && Objects.equals(groupId, that.groupId) && Objects.equals(name, that.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, script, groupId, name);
    }

    public MagicEntity copy() {
        MagicEntity entity = new MagicEntity();
        copyTo(entity);
        return entity;
    }

    public MagicEntity simple() {
        MagicEntity entity = new MagicEntity();
        simple(entity);
        return entity;
    }

    protected void simple(MagicEntity entity) {
        entity.setId(this.id);
        entity.setName(this.name);
        entity.setGroupId(this.groupId);
        entity.setGroupName(this.groupName);
        entity.setePath(this.ePath);
        entity.setCreateBy(this.createBy);
        entity.setCreateTime(this.createTime);
        entity.setUpdateBy(this.updateBy);
        entity.setUpdateTime(this.updateTime);
        entity.setLock(this.lock);
    }

    protected void copyTo(MagicEntity entity) {
        simple(entity);
        entity.setScript(this.script);
        entity.setProperties(this.properties);
    }
}
